/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.test_finder;

import picounit.features.classloader.ClassReloader;
import picounit.features.test_instantiator.Instantiator;

public class ClassReloadingInstantiator implements Instantiator {
	private final ClassReloader classReloader;
	private final Instantiator delegate;

	public ClassReloadingInstantiator(ClassReloader classReloader, Instantiator delegate) {
		this.classReloader = classReloader;
		this.delegate = delegate;
	}
	
	public <T> T instantiate(Class<T> toInstantiate) {
		return delegate.instantiate(classReloader.reloadClass(toInstantiate));
	}
}